<template>
	<div class="tpl33-header"   
   :style="tplItemData.modulePadding || tplItemData.modulePadding ==0?'padding-top:'+tplItemData.modulePadding+'px;padding-bottom:'+tplItemData.modulePadding+'px;':'padding-top:5px;padding-bottom:5px;'">
    <!-- 折叠轮播 -->
    <div ref="getHeight"  class="imgAdv-box">
      <!-- TODO 小程序端用swiper -->
      <wx-swiper class="my-swipe" :style="`height: ${imgadvWxH}`" indicator-color="#ebedf0" :circular="true" indicator-active-color="#FE5000" :autoplay="autoplay" :indicator-dots="showIndicators">
        <wx-swiper-item v-for="(item,index) in tplItemData.dataset" :key="index">
          <a @click="openLink(item.link)">
            <img :src="item.pic" alt="" @load="onImageLoad($event)"/>
          </a>
        </wx-swiper-item>
      </wx-swiper>
    </div>
  </div>
</template>

<script>
  /**
   * @Author: yqe@360shop.cn
   * @Date: 2020年07月08日15:11:21
   * @Last Modified by: yqe@360shop.cn
   * @Last Modified time: 2020年07月08日15:11:21
   */
import Vue from 'vue'
import { openPage } from '@/utils/utils'
import { Swipe, SwipeItem } from 'vant'
Vue.use(Swipe)
Vue.use(SwipeItem)
export default Vue.extend({
    name: 'index',
    data() {
      return {
        imgadvWxH: '0',
        showIndicators: true,
        autoplay: true
      }
    },
    props: {
      tplItemData: {
        type: Object // 传入参数的类型
      }
    },
    methods: {
      // TODO 小程序跳转
      openLink(link) {
          openPage(link)
      },
      // TODO 小程序swiper获取图片高度
      onImageLoad(event){
        const imgHeight = event.detail.height
        if(imgHeight > parseFloat(this.imgadvWxH)){
          this.imgadvWxH = imgHeight+'px'
        }
      },
      
    },

    created() {
  
    }
  })
</script>

<style lang='scss'>
 @import "src/styles/mixin";
.tpl33-header{
  position: relative;
  .imgAdv-box{
    img{
      width: 100%;
    }
  }  
}

</style>
